/**
 * 
 */
package com.jolestar.yayaweibotong.task;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.google.appengine.api.labs.taskqueue.TaskOptions;
import com.jolestar.yayaweibotong.dao.UserDomain;
import com.jolestar.yayaweibotong.service.UserService;

/**
 * @author jolestar@gmail.com
 * 
 */
public class UserQueueCronJob extends QueueCronJob {


	/**
	 * @param queueName
	 */
	public UserQueueCronJob() {
		super(UpdateUserTask.QUENE_NAME+"-job",UpdateUserTask.QUENE_NAME);
	}

	@Override
	protected List<TaskOptions> buildTasks() {
		// TODO 多于100个用户
		List<UserDomain> users = UserService.ServiceHolder.getInstance().getNeedSyncUsers(0, 100);
		if(users.isEmpty()){
			return Collections.emptyList();
		}
		List<TaskOptions> tasks = new ArrayList<TaskOptions>(users.size());
		for (UserDomain user : users) {
			// String name = "put-status-task-"+user.getSafeEmail();
			tasks.add(TaskOptions.Builder.param("email", user.getEmail()));
		}
		return tasks;
	}

}
